package com.woniu.microassetserver.mapper;

import com.woniu.microcommonsserver.entity.DevTypeEntity;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DevTypeMapper {

    /**
     * 根据参数进行分页查询
     * @param devTypeEntity
     * @return
     * @author luoyue
     */
    List<DevTypeEntity> findAllByParams(@Param("dt") DevTypeEntity devTypeEntity);







    /**
     * 新增设备类型信息
     *
     * @param devTypeEntity
     * @return 受影响的行数
     * @author luoyue
     */
    @Options(
            useGeneratedKeys = true,
            keyProperty = "ds.id"
    )
    @Insert("insert into dev_type " +
            "(name,status)" +
            " values(#{dt.name},#{dt.status})")
    int saveDevType(@Param("dt") DevTypeEntity devTypeEntity);



    /**
     * 根据ID查询设备类型
     *
     * @param id
     * @return
     * @author luoyue
     */
    @Results({



            @Result(id = true, property = "id", column = "id", javaType = Long.class),
            @Result(property="name",column="name", javaType = String.class),
            @Result(property="status",column="status", javaType = String.class),



            /*@Result(property = "customerInfo", column = "fk_customer_id", javaType = AssetsParameterBean.class, one =
            @One(select = "com.woniuxy.creditsystem.common.mapper.CustomerMapper.getOneById", fetchType = FetchType.LAZY)),*/
    })
    @Select("select * from dev_type where id = #{id}")
    DevTypeEntity getOneById(Long id);





    /**
     * 修改设备类型
     *v.
     * @param devTypeEntity
     * @return 受影响的行数
     */
    @Update("<script>" +
            "update dev_type" +
            "<set>" +
            "<if test='name != null'>" +
            "name = #{dt.name}," +
            "</if>" +
            "</set>" +
            "where id = #{ap.id}" +
            "</script>")
    int updateDevType(@Param("dt") DevTypeEntity devTypeEntity);


    /**
     * 删除设备类型
     * @param id
     * @return 受影响的行数
     */

    @Delete("delete from dev_type where id = #{id}")
    int deleteDevType(@Param("id")Long id);
}
